package tzjz.example;

import org.xhtmlrenderer.swing.Java2DRenderer;
import org.xhtmlrenderer.util.FSImageWriter;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author renshuting
 * @date 2024/12/27 下午 05:33
 */
public class main {
    public static void main(String[] args) throws IOException {
        String inputFileName="src/main/resources/html/wujia.html";
        int widthImage=1000;
        int heightImage=2000;
        String imageFilePath = "src/main/resources/image/ceshi.png";
        File f = new File(inputFileName);
        Java2DRenderer renderer = new Java2DRenderer(f, widthImage, heightImage);
        BufferedImage image = renderer.getImage();
        FSImageWriter imageWriter = new FSImageWriter();
        imageWriter.setWriteCompressionQuality(0.9f);
        File imgFile = new File(imageFilePath);
        FileOutputStream fout = new FileOutputStream(imgFile);
        imageWriter.write(image, fout);
        fout.close();
    }
}
